# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: Baptiste Jonglez <archlinux at bitsofnetworks dot org>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: ViNS <gladiator@fastwebnet.it>

pkgname=dsniff
pkgver=2.4b1
pkgrel=33
pkgdesc='Collection of tools for network auditing and penetration testing'
url='https://www.monkey.org/~dugsong/dsniff/'
arch=('loong64' 'x86_64')
license=('BSD')
depends=('glibc' 'libpcap' 'openssl' 'libxmu' 'glib2' 'libnet' 'libnids' 'libtirpc')
makedepends=('rpcsvc-proto')
options=('!makeflags')
source=(https://www.monkey.org/~dugsong/${pkgname}/beta/${pkgname}-${pkgver}.tar.gz
        https://ftp.debian.org/debian/pool/main/d/${pkgname}/${pkgname}_2.4b1+debian-30.debian.tar.xz
        dsniff-macof-size-calculation.patch
        dsniff-httppostfix.patch)
sha256sums=('a9803a7a02ddfe5fb9704ce86f0ffc48453c321e88db85810db411ba0841152a'
            '5fcdcc4525e1b4c2aa0208a8543024735bc07096ff1ee6f895eee4e2cf453144'
            'd8f5cc5d14a614410a84a8eaba5a4212ee03466c4fe2fd4a634f5d7c3f688ec7'
            '3efd6ca2267540016e843af3e8d7720d888fd17a73cba410e2c68022fd3a7baf')

prepare() {
  cd "${pkgname}-2.4"

  # apply bundled patches via series
  while IFS='' read -r patch || [[ -n "${patch}" ]]; do
    echo "** Applying patch ${patch}"
    patch -Np1 < "../debian/patches/${patch}"
  done < ../debian/patches/series

  # apply local patches
  for _patch in "${source[@]}"; do
    _patch=${_patch%%::*}
    if [[ "${_patch}" =~ \.patch$ ]]; then
      echo "** Applying patch ${_patch}"
      patch -Np1 < "../${_patch}"
    fi
  done

  autoreconf -fiv
}

build() {
  cd ${pkgname}-2.4
  ./configure \
    --prefix=/usr \
    --sbindir=/usr/bin
  make
}

package() {
  cd ${pkgname}-2.4
  make install_prefix="${pkgdir}" install
  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 CHANGES README -t "${pkgdir}/usr/share/doc/${pkgname}"
}

# vim: ts=2 sw=2 et:
